# -*- coding: utf-8 -*-
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import annotations

from typing import MutableMapping, MutableSequence

from google.protobuf import field_mask_pb2  # type: ignore
from google.protobuf import timestamp_pb2  # type: ignore
import proto  # type: ignore

__protobuf__ = proto.module(
    package="google.shopping.merchant.conversions.v1beta",
    manifest={
        "ConversionSource",
        "AttributionSettings",
        "GoogleAnalyticsLink",
        "MerchantCenterDestination",
        "CreateConversionSourceRequest",
        "UpdateConversionSourceRequest",
        "DeleteConversionSourceRequest",
        "UndeleteConversionSourceRequest",
        "GetConversionSourceRequest",
        "ListConversionSourcesRequest",
        "ListConversionSourcesResponse",
    },
)


class ConversionSource(proto.Message):
    r"""Represents a conversion source owned by a Merchant account. A
    merchant account can have up to 200 conversion sources.

    This message has `oneof`_ fields (mutually exclusive fields).
    For each oneof, at most one member field can be set at the same time.
    Setting any member of the oneof automatically clears all other
    members.

    .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields

    Attributes:
        google_analytics_link (google.shopping.merchant_conversions_v1beta.types.GoogleAnalyticsLink):
            Immutable. Conversion Source of type "Link to
            Google Analytics Property".

            This field is a member of `oneof`_ ``source_data``.
        merchant_center_destination (google.shopping.merchant_conversions_v1beta.types.MerchantCenterDestination):
            Conversion Source of type "Merchant Center
            Tag Destination".

            This field is a member of `oneof`_ ``source_data``.
        name (str):
            Output only. Identifier. Generated by the Content API upon
            creation of a new ``ConversionSource``. Format: [a-z]{4}:.+
            The four characters before the colon represent the type of
            conversio source. Content after the colon represents the ID
            of the conversion source within that type. The ID of two
            different conversion sources might be the same across
            different types. The following type prefixes are supported:

            - galk: For GoogleAnalyticsLink sources.
            - mcdn: For MerchantCenterDestination sources.
        state (google.shopping.merchant_conversions_v1beta.types.ConversionSource.State):
            Output only. Current state of this conversion
            source. Can't be edited through the API.
        expire_time (google.protobuf.timestamp_pb2.Timestamp):
            Output only. The time when an archived
            conversion source becomes permanently deleted
            and is no longer available to undelete.
        controller (google.shopping.merchant_conversions_v1beta.types.ConversionSource.Controller):
            Output only. Controller of the conversion
            source.
    """

    class State(proto.Enum):
        r"""Represents state of the conversion source.

        Values:
            STATE_UNSPECIFIED (0):
                Conversion source has unspecified state.
            ACTIVE (1):
                Conversion source is fully functional.
            ARCHIVED (2):
                Conversion source has been archived in the
                last 30 days and not currently functional. Can
                be restored using the undelete method.
            PENDING (3):
                Conversion source creation has started but
                not fully finished yet.
        """
        STATE_UNSPECIFIED = 0
        ACTIVE = 1
        ARCHIVED = 2
        PENDING = 3

    class Controller(proto.Enum):
        r"""Entity controlling the conversion source.

        Values:
            CONTROLLER_UNSPECIFIED (0):
                Default value. This value is unused.
            MERCHANT (1):
                Controlled by the Merchant who owns the
                Conversion Source.
            YOUTUBE_AFFILIATES (2):
                Controlled by the YT Affiliates program.
        """
        CONTROLLER_UNSPECIFIED = 0
        MERCHANT = 1
        YOUTUBE_AFFILIATES = 2

    google_analytics_link: "GoogleAnalyticsLink" = proto.Field(
        proto.MESSAGE,
        number=3,
        oneof="source_data",
        message="GoogleAnalyticsLink",
    )
    merchant_center_destination: "MerchantCenterDestination" = proto.Field(
        proto.MESSAGE,
        number=4,
        oneof="source_data",
        message="MerchantCenterDestination",
    )
    name: str = proto.Field(
        proto.STRING,
        number=1,
    )
    state: State = proto.Field(
        proto.ENUM,
        number=5,
        enum=State,
    )
    expire_time: timestamp_pb2.Timestamp = proto.Field(
        proto.MESSAGE,
        number=6,
        message=timestamp_pb2.Timestamp,
    )
    controller: Controller = proto.Field(
        proto.ENUM,
        number=7,
        enum=Controller,
    )


class AttributionSettings(proto.Message):
    r"""Represents attribution settings for conversion sources
    receiving pre-attribution data.

    Attributes:
        attribution_lookback_window_days (int):
            Required. Lookback windows (in days) used for
            attribution in this source. Supported values are
            7, 30, 40.
        attribution_model (google.shopping.merchant_conversions_v1beta.types.AttributionSettings.AttributionModel):
            Required. Attribution model.
        conversion_type (MutableSequence[google.shopping.merchant_conversions_v1beta.types.AttributionSettings.ConversionType]):
            Immutable. Unordered list. List of different
            conversion types a conversion event can be
            classified as. A standard "purchase" type will
            be automatically created if this list is empty
            at creation time.
    """

    class AttributionModel(proto.Enum):
        r"""The attribution model used for this source. We support the
        same set of models offered by Google Analytics 4, as described
        in:

        https://support.google.com/analytics/answer/10596866.

        Values:
            ATTRIBUTION_MODEL_UNSPECIFIED (0):
                Unspecified model.
            CROSS_CHANNEL_LAST_CLICK (1):
                Cross-channel Last Click model.
            ADS_PREFERRED_LAST_CLICK (2):
                Ads-preferred Last Click model.
            CROSS_CHANNEL_DATA_DRIVEN (5):
                Cross-channel Data Driven model.
            CROSS_CHANNEL_FIRST_CLICK (6):
                Cross-channel First Click model.
            CROSS_CHANNEL_LINEAR (7):
                Cross-channel Linear model.
            CROSS_CHANNEL_POSITION_BASED (8):
                Cross-channel Position Based model.
            CROSS_CHANNEL_TIME_DECAY (9):
                Cross-channel Time Decay model.
        """
        ATTRIBUTION_MODEL_UNSPECIFIED = 0
        CROSS_CHANNEL_LAST_CLICK = 1
        ADS_PREFERRED_LAST_CLICK = 2
        CROSS_CHANNEL_DATA_DRIVEN = 5
        CROSS_CHANNEL_FIRST_CLICK = 6
        CROSS_CHANNEL_LINEAR = 7
        CROSS_CHANNEL_POSITION_BASED = 8
        CROSS_CHANNEL_TIME_DECAY = 9

    class ConversionType(proto.Message):
        r"""Message representing a types of conversion events

        Attributes:
            name (str):
                Output only. Conversion event name, as it'll
                be reported by the client.
            report (bool):
                Output only. Option indicating if the type
                should be included in Merchant Center reporting.
        """

        name: str = proto.Field(
            proto.STRING,
            number=1,
        )
        report: bool = proto.Field(
            proto.BOOL,
            number=2,
        )

    attribution_lookback_window_days: int = proto.Field(
        proto.INT32,
        number=1,
    )
    attribution_model: AttributionModel = proto.Field(
        proto.ENUM,
        number=2,
        enum=AttributionModel,
    )
    conversion_type: MutableSequence[ConversionType] = proto.RepeatedField(
        proto.MESSAGE,
        number=3,
        message=ConversionType,
    )


class GoogleAnalyticsLink(proto.Message):
    r""" "Google Analytics Link" sources can be used to get conversion
    data from an existing Google Analytics property into the linked
    Merchant Center account.

    Attributes:
        property_id (int):
            Required. Immutable. ID of the Google
            Analytics property the merchant is linked to.
        attribution_settings (google.shopping.merchant_conversions_v1beta.types.AttributionSettings):
            Output only. Attribution settings for the
            linked Google Analytics property.
        property (str):
            Output only. Name of the Google Analytics
            property the merchant is linked to.
    """

    property_id: int = proto.Field(
        proto.INT64,
        number=1,
    )
    attribution_settings: "AttributionSettings" = proto.Field(
        proto.MESSAGE,
        number=2,
        message="AttributionSettings",
    )
    property: str = proto.Field(
        proto.STRING,
        number=3,
    )


class MerchantCenterDestination(proto.Message):
    r""" "Merchant Center Destination" sources can be used to send
    conversion events from an online store using a Google tag
    directly to a Merchant Center account where the source is
    created.

    Attributes:
        destination (str):
            Output only. Merchant Center Destination ID.
        attribution_settings (google.shopping.merchant_conversions_v1beta.types.AttributionSettings):
            Required. Attribution settings being used for
            the Merchant Center Destination.
        display_name (str):
            Required. Merchant-specified display name for
            the destination. This is the name that
            identifies the conversion source within the
            Merchant Center UI. Limited to 64 characters.
        currency_code (str):
            Required. Three-letter currency code (ISO
            4217). The currency code defines in which
            currency the conversions sent to this
            destination will be reported in Merchant Center.
    """

    destination: str = proto.Field(
        proto.STRING,
        number=1,
    )
    attribution_settings: "AttributionSettings" = proto.Field(
        proto.MESSAGE,
        number=2,
        message="AttributionSettings",
    )
    display_name: str = proto.Field(
        proto.STRING,
        number=3,
    )
    currency_code: str = proto.Field(
        proto.STRING,
        number=4,
    )


class CreateConversionSourceRequest(proto.Message):
    r"""Request message for the CreateConversionSource method.

    Attributes:
        parent (str):
            Required. The merchant account that will own
            the new conversion source. Format:
            accounts/{account}
        conversion_source (google.shopping.merchant_conversions_v1beta.types.ConversionSource):
            Required. The conversion source description.
            A new ID will be automatically assigned to it
            upon creation.
    """

    parent: str = proto.Field(
        proto.STRING,
        number=1,
    )
    conversion_source: "ConversionSource" = proto.Field(
        proto.MESSAGE,
        number=2,
        message="ConversionSource",
    )


class UpdateConversionSourceRequest(proto.Message):
    r"""Request message for the UpdateConversionSource method.

    Attributes:
        conversion_source (google.shopping.merchant_conversions_v1beta.types.ConversionSource):
            Required. The new version of the conversion source data.
            Format:
            accounts/{account}/conversionSources/{conversion_source}
        update_mask (google.protobuf.field_mask_pb2.FieldMask):
            Required. List of fields being updated.
    """

    conversion_source: "ConversionSource" = proto.Field(
        proto.MESSAGE,
        number=1,
        message="ConversionSource",
    )
    update_mask: field_mask_pb2.FieldMask = proto.Field(
        proto.MESSAGE,
        number=2,
        message=field_mask_pb2.FieldMask,
    )


class DeleteConversionSourceRequest(proto.Message):
    r"""Request message for the DeleteConversionSource method.

    Attributes:
        name (str):
            Required. The name of the conversion source to be deleted.
            Format:
            accounts/{account}/conversionSources/{conversion_source}
    """

    name: str = proto.Field(
        proto.STRING,
        number=1,
    )


class UndeleteConversionSourceRequest(proto.Message):
    r"""Request message for the UndeleteConversionSource method.

    Attributes:
        name (str):
            Required. The name of the conversion source to be undeleted.
            Format:
            accounts/{account}/conversionSources/{conversion_source}
    """

    name: str = proto.Field(
        proto.STRING,
        number=1,
    )


class GetConversionSourceRequest(proto.Message):
    r"""Request message for the GetConversionSource method.

    Attributes:
        name (str):
            Required. The name of the conversion source to be fetched.
            Format:
            accounts/{account}/conversionsources/{conversion_source}
    """

    name: str = proto.Field(
        proto.STRING,
        number=1,
    )


class ListConversionSourcesRequest(proto.Message):
    r"""Request message for the ListConversionSources method.

    Attributes:
        parent (str):
            Required. The merchant account who owns the
            collection of conversion sources. Format:
            accounts/{account}
        page_size (int):
            Optional. The maximum number of conversion sources to return
            in a page. If no ``page_size`` is specified, ``100`` is used
            as the default value. The maximum value is ``200``. Values
            above ``200`` will be coerced to ``200``. Regardless of
            pagination, at most ``200`` conversion sources are returned
            in total.
        page_token (str):
            Optional. Page token.
        show_deleted (bool):
            Optional. Show deleted (archived) option.
    """

    parent: str = proto.Field(
        proto.STRING,
        number=1,
    )
    page_size: int = proto.Field(
        proto.INT32,
        number=2,
    )
    page_token: str = proto.Field(
        proto.STRING,
        number=3,
    )
    show_deleted: bool = proto.Field(
        proto.BOOL,
        number=4,
    )


class ListConversionSourcesResponse(proto.Message):
    r"""Response message for the ListConversionSources method.

    Attributes:
        conversion_sources (MutableSequence[google.shopping.merchant_conversions_v1beta.types.ConversionSource]):
            List of conversion sources.
        next_page_token (str):
            Token to be used to fetch the next results
            page.
    """

    @property
    def raw_page(self):
        return self

    conversion_sources: MutableSequence["ConversionSource"] = proto.RepeatedField(
        proto.MESSAGE,
        number=1,
        message="ConversionSource",
    )
    next_page_token: str = proto.Field(
        proto.STRING,
        number=2,
    )


__all__ = tuple(sorted(__protobuf__.manifest))
